/*
 * RSFloat.cpp
 *
 *  Created on: 2010/03/17
 *      Author: alexandre
 */

#include "RSFloat.h"
#include "RSSerializer.h"

namespace Realsphere {

    RSFloat::RSFloat ( ) :
        RSValueElement ()
    {
        SetTag( RS_FLOAT_TAG, false );
    }


    RSFloat::RSFloat ( const QString& rScopeId ) :
        RSValueElement ( rScopeId )
    {
        SetTag( RS_FLOAT_TAG, false );
    }


    RSFloat::RSFloat ( const float& rValue ) :
        RSValueElement ()
    {
        SetTag( RS_FLOAT_TAG, false );
        SetValue ( rValue, false );
    }


    RSFloat::RSFloat ( const QString& rScopeId, float& rValue ) :
            RSValueElement ( rScopeId )
    {
        SetTag( RS_FLOAT_TAG, false );
        SetValue ( rValue, false );
    }


    RSValueType RSFloat::ValueType () const
    {
        return RS_FLOAT;
    }


    RSDataSize RSFloat::SizeOf () const
    {
        return sizeof(float);
    }


    RSDataPointer RSFloat::DataPointer()
    {
        return &mValue;
    }


    QString RSFloat::ToString () const
    {
        return RSSerializer::serialize(mValue);
    }


    float RSFloat::Value () const
    {
        return mValue;
    }


    void RSFloat::SetValue ( const float& rValue, bool rEmit )
    {
        mValue = rValue;
        if ( rEmit )
            emit ValueChanged();
    }


    void RSFloat::SetValue ( const RSFloat& rValue, bool rEmit )
    {
        SetValue ( rValue.Value(), rEmit );
    }


    RSFloat& RSFloat::operator=( const float& rValue )
    {
        SetValue( rValue );
        return *this;
    }

    RSFloat& RSFloat::operator=( const RSFloat& rValue )
    {
        SetValue( rValue );
        return *this;
    }
}
